# Creates pseudo distributed tomcat 8.5.75
# Author: glacier
FROM openanolis/anolisos:8.4-x86_64

LABEL image.authors="glacier" \
  image.version="8.5.75"

USER root

# # 下载 tomcat
# ARG OpenJDK8 https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.75/bin/apache-tomcat-8.5.75.tar.gz
# # 下载 openjdk
# ARG tomcat85 https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u322-b06/OpenJDK8U-jdk_x64_linux_hotspot_8u322b06.tar.gz

# 添加
COPY res/*.tar.gz /tmp/

ARG JAVA_PATH=/usr/local/java/default \
  CATALINA_PATH=/usr/local/apache-tomcat-8.5

# 部署jdk和tomcat
RUN set -x; \
  dnf install -y curl tar \
  && dnf clean all \
  # && curl -Lo /tmp/OpenJDK8U-jdk_x64_linux.tar.gz $OpenJDK8 \
  # && curl -Lo /tmp/apache-tomcat-8.5.75.tar.gz $tomcat85 \
  && mkdir -p /usr/local/java \
  && tar -zxvf /tmp/OpenJDK8U-jdk_x64_linux.tar.gz -C /usr/local/java \
  && tar -zxvf /tmp/apache-tomcat-8.5.75.tar.gz -C /usr/local \
  && ln -sf /usr/local/java/jdk8u322-b06 $JAVA_PATH \
  && mv /usr/local/apache-tomcat-8.5.75 $CATALINA_PATH \
  && rm -rf /tmp/*.tar.gz

# 设置环境变量
ENV JAVA_HOME=$JAVA_PATH \
  CATALINA_HOME=$CATALINA_PATH \
  CLASSPATH=.:$JAVA_PATH/lib/dt.jar:$JAVA_PATH/lib/tools.jar \
  CATALINA_BASH=$CATALINA_PATH \
  PATH=$PATH:$JAVA_PATH/bin:$CATALINA_PATH/bin

# 设置工作目录
WORKDIR $CATALINA_PATH

# 设置挂载卷
VOLUME ["$CATALINA_PATH/logs", "$CATALINA_PATH/temp", "$CATALINA_PATH/work", "$CATALINA_PATH/webapps"]

EXPOSE 8080

CMD ["catalina.sh", "run"]
